package org.skydiveapplibrary.data;

import java.util.ArrayList;
import java.util.List;

import org.skydiveapplibrary.R;

public enum WeightUnit
{
	Pounds (R.string.weight_unit_pounds),
	Kilograms (R.string.weight_unit_kilograms);
	
	// conversion ratios
	private static final float KG_TO_LBS = new Float(2.20462262);
	
	private int resourceId;
	
	WeightUnit(int resourceId)
	{
		this.resourceId = resourceId;
	}
	
	public int getResourceId()
	{
		return resourceId; 
	}
	
	public static List<WeightUnit> getItems()
	{
		List<WeightUnit> items = new ArrayList<WeightUnit>();
		for (WeightUnit item: WeightUnit.values())
		{
			items.add(item);
		}
		return items;
	}
	
	public static float convert(float value, WeightUnit from, WeightUnit to)
	{
		float result = value;
		if (from == Kilograms && to == Pounds)
		{
			// kg to lbs
			result = value * KG_TO_LBS; 
		}
		else if (from == Pounds && to == Kilograms)
		{
			// lbs to kg
			result = value / KG_TO_LBS;
		}
		
		return result;
	}
}
